<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   【scikit-learn】学习Python来分类现实世界的数据  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/5583.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466458558: Accept with keywords: (title(0.428571428571):社区,Python,现实,分类,世界,数盟,数据, topn(0.466666666667):社区,数盟,行业资讯,数组,数据挖掘,阈值,交叉,Python,标签,模型,准确率,花瓣,可视化,文章,子集,参数,数据,结果,样本,品种,检验,散点图,维度,基础架构,花朵,编程语言,利用,分类,人工智能,序列).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    【scikit-learn】学习Python来分类现实世界的数据
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    【scikit-learn】学习Python来分类现实世界的数据 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,79] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/devl">
       编程语言
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/5583.html">
          【scikit-learn】学习Python来分类现实世界的数据
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          5,395 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/devl" rel="category tag">
          编程语言
         </a>
         ,
         <a href="http://dataunion.org/category/tech/ai" rel="category tag">
          人工智能
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <h3>
        作者： JasonDing
       </h3>
       <h3>
        引入
       </h3>
       <p>
        一个机器可以根据照片来辨别鲜花的品种吗？在机器学习角度，这其实是一个分类问题，即机器根据不同品种鲜花的数据进行学习，使其可以对未标记的测试图片数据进行分类。这一小节，我们还是从scikit-learn出发，理解基本的分类原则，多动手实践。
       </p>
       <h3>
        Iris数据集
       </h3>
       <p>
        Iris flower数据集是1936年由Sir Ronald Fisher引入的经典多维数据集，可以作为判别分析（discriminant analysis）的样本。该数据集包含Iris花的三个品种(Iris setosa, Iris virginica and Iris versicolor)各50个样本，每个样本还有4个特征参数（分别是萼片&lt;sepals&gt;的长宽和花瓣&lt;petals&gt;的长 宽，以厘米为单位），Fisher利用这个数据集开发了一个线性判别模型来辨别花朵的品种。基于Fisher的线性判别模型，该数据集成为了机器学习中各 种分类技术的典型实验案例。
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2014/12/141226110284201.jpg"/>
       </p>
       <div>
        <p>
         现在我们要解决的分类问题是，当我们看到一个新的iris花朵，我们能否根据以上测量参数成功预测新iris花朵的品种。
        </p>
        <p>
         我们利用给定标签的数据，设计一种规则进而应用到其他样本中做预测，这是基本的监督问题（分类问题）。
        </p>
        <p>
         由于iris数据集样本量和维度都很小，所以可以方便进行可视化和操作。
        </p>
       </div>
       <h3>
        数据的可视化(visualization)
       </h3>
       <p>
        scikit-learn自带有一些经典的数据集，比如用于分类的iris和digits数据集，还有用于回归分析的boston house prices数据集。可以通过下面的方式载入数据：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576861a446be1234034635" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          &lt;span class="keyword"&gt;from&lt;/span&gt; sklearn &lt;span class="keyword"&gt;import&lt;/span&gt; datasets
iris = datasets.load_iris()
digits = datasets.load_digits()
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576861a446be1234034635-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446be1234034635-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576861a446be1234034635-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576861a446be1234034635-1">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                import
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                datasets
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446be1234034635-2">
               <span class="crayon-v">
                iris
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                datasets
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                load_iris
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446be1234034635-3">
               <span class="crayon-v">
                digits
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                datasets
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                load_digits
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0018 seconds] -->
       <p>
        该数据集是一种字典结构，数据存储在.data成员中，输出标签存储在.target成员中。
       </p>
       <h4>
        画出任意两维的数据散点图
       </h4>
       <p>
        可以用下面的方式画出任意两个维度的散点图，这里以第一维sepal length和第二维数据sepal width为例：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576861a446bf0799662885" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          from sklearn &lt;span class="keyword"&gt;import&lt;/span&gt; datasets
&lt;span class="keyword"&gt;import&lt;/span&gt; matplotlib.pyplot as plt
&lt;span class="keyword"&gt;import&lt;/span&gt; numpy as np
iris = datasets.load_iris()
irisFeatures = iris[&lt;span class="string"&gt;"data"&lt;/span&gt;]
irisFeaturesName = iris[&lt;span class="string"&gt;"feature_names"&lt;/span&gt;]
irisLabels = iris[&lt;span class="string"&gt;"target"&lt;/span&gt;]
def scatter_plot(dim1, dim2):
    &lt;span class="keyword"&gt;for&lt;/span&gt; t,marker,color in zip(xrange(&lt;span class="number"&gt;3&lt;/span&gt;),&lt;span class="string"&gt;"&amp;gt;ox"&lt;/span&gt;,&lt;span class="string"&gt;"rgb"&lt;/span&gt;):
           # zip()接受任意多个序列参数，返回一个元组tuple列表
        # 用不同的标记和颜色画出每种品种iris花朵的前两维数据
        # We plot each &lt;span class="class"&gt;&lt;span class="keyword"&gt;class&lt;/span&gt; &lt;span class="title"&gt;on&lt;/span&gt; &lt;span class="title"&gt;its&lt;/span&gt; &lt;span class="title"&gt;own&lt;/span&gt; &lt;span class="title"&gt;to&lt;/span&gt; &lt;span class="title"&gt;get&lt;/span&gt; &lt;span class="title"&gt;different&lt;/span&gt; &lt;span class="title"&gt;colored&lt;/span&gt; &lt;span class="title"&gt;markers&lt;/span&gt;
        &lt;span class="title"&gt;plt&lt;/span&gt;.&lt;span class="title"&gt;scatter&lt;/span&gt;(&lt;span class="title"&gt;irisFeatures&lt;/span&gt;[&lt;span class="title"&gt;irisLabels&lt;/span&gt; == &lt;span class="title"&gt;t&lt;/span&gt;,&lt;span class="title"&gt;dim1&lt;/span&gt;],
        &lt;span class="title"&gt;irisFeatures&lt;/span&gt;[&lt;span class="title"&gt;irisLabels&lt;/span&gt; == &lt;span class="title"&gt;t&lt;/span&gt;,&lt;span class="title"&gt;dim2&lt;/span&gt;],&lt;span class="title"&gt;marker&lt;/span&gt;=&lt;span class="title"&gt;marker&lt;/span&gt;,&lt;span class="title"&gt;c&lt;/span&gt;=&lt;span class="title"&gt;color&lt;/span&gt;)
    &lt;span class="title"&gt;dim_meaning&lt;/span&gt; = {&lt;/span&gt;&lt;span class="number"&gt;0&lt;/span&gt;:&lt;span class="string"&gt;'setal length'&lt;/span&gt;,&lt;span class="number"&gt;1&lt;/span&gt;:&lt;span class="string"&gt;'setal width'&lt;/span&gt;,&lt;span class="number"&gt;2&lt;/span&gt;:&lt;span class="string"&gt;'petal length'&lt;/span&gt;,&lt;span class="number"&gt;3&lt;/span&gt;:&lt;span class="string"&gt;'petal width'&lt;/span&gt;}
    plt.xlabel(dim_meaning.get(dim1))
    plt.ylabel(dim_meaning.get(dim2))
plt.subplot(&lt;span class="number"&gt;231&lt;/span&gt;)
scatter_plot(&lt;span class="number"&gt;0&lt;/span&gt;,&lt;span class="number"&gt;1&lt;/span&gt;)
plt.subplot(&lt;span class="number"&gt;232&lt;/span&gt;)
scatter_plot(&lt;span class="number"&gt;0&lt;/span&gt;,&lt;span class="number"&gt;2&lt;/span&gt;)
plt.subplot(&lt;span class="number"&gt;233&lt;/span&gt;)
scatter_plot(&lt;span class="number"&gt;0&lt;/span&gt;,&lt;span class="number"&gt;3&lt;/span&gt;)
plt.subplot(&lt;span class="number"&gt;234&lt;/span&gt;)
scatter_plot(&lt;span class="number"&gt;1&lt;/span&gt;,&lt;span class="number"&gt;2&lt;/span&gt;)
plt.subplot(&lt;span class="number"&gt;235&lt;/span&gt;)
scatter_plot(&lt;span class="number"&gt;1&lt;/span&gt;,&lt;span class="number"&gt;3&lt;/span&gt;)
plt.subplot(&lt;span class="number"&gt;236&lt;/span&gt;)
scatter_plot(&lt;span class="number"&gt;2&lt;/span&gt;,&lt;span class="number"&gt;3&lt;/span&gt;)
plt.show()
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bf0799662885-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bf0799662885-30">
               30
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576861a446bf0799662885-1">
               <span class="crayon-e">
                from
               </span>
               <span class="crayon-v">
                sklearn
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                import
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                datasets
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-2">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                import
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matplotlib
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                pyplot
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-3">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                import
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                numpy
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                np
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-4">
               <span class="crayon-v">
                iris
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                datasets
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                load_iris
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-5">
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                iris
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                "data"
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-6">
               <span class="crayon-v">
                irisFeaturesName
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                iris
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                "feature_names"
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-7">
               <span class="crayon-v">
                irisLabels
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                iris
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                "target"
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-8">
               <span class="crayon-e">
                def
               </span>
               <span class="crayon-e">
                scatter_plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                dim1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                dim2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                marker
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-e">
                color
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                zip
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                xrange
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                "&amp;gt;ox"
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                "rgb"
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # zip()接受任意多个序列参数，返回一个元组tuple列表
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # 用不同的标记和颜色画出每种品种iris花朵的前两维数据
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                # We plot each &lt;span class="class"&gt;&lt;span class="keyword"&gt;class&lt;/span&gt; &lt;span class="title"&gt;on&lt;/span&gt; &lt;span class="title"&gt;its&lt;/span&gt; &lt;span class="title"&gt;own&lt;/span&gt; &lt;span class="title"&gt;to&lt;/span&gt; &lt;span class="title"&gt;get&lt;/span&gt; &lt;span class="title"&gt;different&lt;/span&gt; &lt;span class="title"&gt;colored&lt;/span&gt; &lt;span class="title"&gt;markers&lt;/span&gt;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                scatter
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                irisLabels
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                dim1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                irisLabels
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                dim2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                marker
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;=
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                marker
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                c
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;=
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                dim_meaning
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'setal length'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'setal width'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'petal length'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'petal width'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                xlabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                dim_meaning
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                get
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                dim1
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                ylabel
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                dim_meaning
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                get
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                dim2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-18">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                subplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                231
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-19">
               <span class="crayon-e">
                scatter_plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-20">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                subplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                232
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-21">
               <span class="crayon-e">
                scatter_plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-22">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                subplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                233
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-23">
               <span class="crayon-e">
                scatter_plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-24">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                subplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                234
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-25">
               <span class="crayon-e">
                scatter_plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-26">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                subplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                235
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-27">
               <span class="crayon-e">
                scatter_plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-28">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                subplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                236
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bf0799662885-29">
               <span class="crayon-e">
                scatter_plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                3
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bf0799662885-30">
               <span class="crayon-v">
                plt
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                show
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.1016 seconds] -->
       <p>
        效果如图：
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2014/12/141226110284202.jpg"/>
       </p>
       <h3>
        构建分类模型
       </h3>
       <h4>
        根据某一维度的阈值进行分类
       </h4>
       <p>
        如果我们的目标是区别这三种花朵，我们可以做一些假设。比如花瓣的长度(petal length)好像将Iris Setosa品种与其它两种花朵区分开来。我们可以以此来写一段小代码看看这个属性的边界是什么：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576861a446bfa209500049" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          petalLength = irisFeatures[:,&lt;span class="number"&gt;2&lt;/span&gt;] &lt;span class="comment"&gt;#select the third column,since the features is 150*4&lt;/span&gt;
isSetosa = (irisLabels == &lt;span class="number"&gt;0&lt;/span&gt;) &lt;span class="comment"&gt;#label 0 means iris Setosa&lt;/span&gt;
maxSetosaPlength = petalLength[isSetosa].max()
minNonSetosaPlength = petalLength[~isSetosa].min()

&lt;span class="keyword"&gt;print&lt;/span&gt; (&lt;span class="string"&gt;'Maximum of setosa:{0} '&lt;/span&gt;.format(maxSetosaPlength))
&lt;span class="keyword"&gt;print&lt;/span&gt; (&lt;span class="string"&gt;'Minimum of others:{0} '&lt;/span&gt;.format(minNonSetosaPlength))

&lt;span class="string"&gt;'''
显示结果是：
Maximum of setosa:1.9 
Minimum of others:3.0 
'''&lt;/span&gt;
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576861a446bfa209500049-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bfa209500049-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bfa209500049-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bfa209500049-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bfa209500049-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bfa209500049-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bfa209500049-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bfa209500049-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bfa209500049-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bfa209500049-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bfa209500049-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446bfa209500049-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576861a446bfa209500049-13">
               13
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576861a446bfa209500049-1">
               <span class="crayon-v">
                petalLength
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "comment"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-p">
                #select the third column,since the features is 150*4&lt;/span&gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bfa209500049-2">
               <span class="crayon-v">
                isSetosa
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                irisLabels
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "comment"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-p">
                #label 0 means iris Setosa&lt;/span&gt;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bfa209500049-3">
               <span class="crayon-v">
                maxSetosaPlength
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                petalLength
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                isSetosa
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                max
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bfa209500049-4">
               <span class="crayon-v">
                minNonSetosaPlength
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                petalLength
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-v">
                isSetosa
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                min
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bfa209500049-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bfa209500049-6">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                print
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'Maximum of setosa:{0} '
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                format
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                maxSetosaPlength
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bfa209500049-7">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                print
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'Minimum of others:{0} '
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                format
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                minNonSetosaPlength
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bfa209500049-8">
              </div>
              <div class="crayon-line" id="crayon-576861a446bfa209500049-9">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                ''
               </span>
               <span class="crayon-s">
                '
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bfa209500049-10">
               <span class="crayon-s">
                显示结果是：
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bfa209500049-11">
               <span class="crayon-s">
                Maximum of setosa:1.9
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446bfa209500049-12">
               <span class="crayon-s">
                Minimum of others:3.0
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446bfa209500049-13">
               <span class="crayon-s">
                '
               </span>
               <span class="crayon-s">
                ''
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0208 seconds] -->
       <p>
       </p>
       <div>
        <p>
         我们根据实验结果可以建立一个简单的分类模型，如果花瓣长度小于2，就是Iris Setosa花朵，否则就是其他两种花朵。
        </p>
        <p>
         这个模型的结构非常简单，是由数据的一个维度阈值来确定的。我们通过实验确定这个维度的最佳阈值。
        </p>
        <p>
         以上的例子将Iris Setosa花朵和其他两种花朵很容易的分开了，然而我们不能立即确定Iris Virginica花朵和Iris Versicolor花朵的最佳阈值，我们甚至发现，我们无法根据某一维度的阈值将这两种类别很完美的分开。
        </p>
       </div>
       <h4>
        比较准确率来得到阈值
       </h4>
       <p>
        我们先选出非Setosa的花朵。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576861a446c02266440862" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          &lt;span class="setting"&gt;irisFeatures = &lt;span class="value"&gt;irisFeatures[~isSetosa]&lt;/span&gt;&lt;/span&gt;
&lt;span class="setting"&gt;labels = &lt;span class="value"&gt;irisLabels[~isSetosa]&lt;/span&gt;&lt;/span&gt;
&lt;span class="setting"&gt;isVirginica = &lt;span class="value"&gt;(labels == &lt;span class="number"&gt;2&lt;/span&gt;)    #label &lt;span class="number"&gt;2&lt;/span&gt; means iris virginica&lt;/span&gt;&lt;/span&gt;
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576861a446c02266440862-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c02266440862-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c02266440862-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576861a446c02266440862-1">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "setting"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "value"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-v">
                isSetosa
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c02266440862-2">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "setting"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                labels
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "value"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                irisLabels
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-v">
                isSetosa
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c02266440862-3">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "setting"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                isVirginica
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "value"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                labels
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                #label &lt;span class="number"&gt;2&lt;/span&gt; means iris virginica&lt;/span&gt;&lt;/span&gt;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0034 seconds] -->
       <p>
        这里我们非常依赖NumPy对于数组的操作，isSetosa是一个Boolean值数组，我们可以用它来选择出非Setosa的花朵。最后，我 们还构造了一个新的Boolean数组，isVirginica。接下来，我们对每一维度的特征写一个循环小程序，然后看一下哪一个阈值能得到更好的准确 率。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576861a446c09392798894" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          &lt;span class="comment"&gt;# search the threshold between virginica and versicolor&lt;/span&gt;
irisFeatures = irisFeatures[~isSetosa]
labels = irisLabels[~isSetosa]
isVirginica = (labels == &lt;span class="number"&gt;2&lt;/span&gt;)	&lt;span class="comment"&gt;#label 2 means iris virginica&lt;/span&gt;
bestAccuracy = -&lt;span class="number"&gt;1.0&lt;/span&gt;
&lt;span class="keyword"&gt;for&lt;/span&gt; fi &lt;span class="keyword"&gt;in&lt;/span&gt; xrange(irisFeatures.shape[&lt;span class="number"&gt;1&lt;/span&gt;]):
thresh = irisFeatures[:,fi].copy()
thresh.sort()
&lt;span class="keyword"&gt;for&lt;/span&gt; t &lt;span class="keyword"&gt;in&lt;/span&gt; thresh:
pred = (irisFeatures[:,fi] &amp;gt; t)
acc = (pred == isVirginica).mean()
&lt;span class="keyword"&gt;if&lt;/span&gt; acc &amp;gt; bestAccuracy:
bestAccuracy = acc;
bestFeatureIndex = fi;
bestThreshold = t;
&lt;span class="keyword"&gt;print&lt;/span&gt; &lt;span class="string"&gt;'Best Accuracy:\t\t'&lt;/span&gt;,bestAccuracy
&lt;span class="keyword"&gt;print&lt;/span&gt; &lt;span class="string"&gt;'Best Feature Index:\t'&lt;/span&gt;,bestFeatureIndex
&lt;span class="keyword"&gt;print&lt;/span&gt; &lt;span class="string"&gt;'Best Threshold:\t\t'&lt;/span&gt;,bestThreshold
&lt;span class="string"&gt;'''
最终结果：
Best Accuracy:		0.94
Best Feature Index:	3
Best Threshold:		1.6
'''&lt;/span&gt;
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c09392798894-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c09392798894-24">
               24
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576861a446c09392798894-1">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "comment"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-p">
                # search the threshold between virginica and versicolor&lt;/span&gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-2">
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-v">
                isSetosa
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-3">
               <span class="crayon-v">
                labels
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                irisLabels
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-v">
                isSetosa
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-4">
               <span class="crayon-v">
                isVirginica
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                labels
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "comment"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-p">
                #label 2 means iris virginica&lt;/span&gt;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-5">
               <span class="crayon-v">
                bestAccuracy
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-6">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                xrange
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                shape
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-7">
               <span class="crayon-v">
                thresh
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                copy
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-8">
               <span class="crayon-v">
                thresh
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                sort
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-9">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                thresh
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-10">
               <span class="crayon-v">
                pred
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-11">
               <span class="crayon-v">
                acc
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                pred
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                isVirginica
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                mean
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-12">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                acc
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                bestAccuracy
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-13">
               <span class="crayon-v">
                bestAccuracy
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                acc
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-14">
               <span class="crayon-v">
                bestFeatureIndex
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-15">
               <span class="crayon-v">
                bestThreshold
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-16">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                print
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'Best Accuracy:\t\t'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                bestAccuracy
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-17">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                print
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'Best Feature Index:\t'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                bestFeatureIndex
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-18">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                print
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'Best Threshold:\t\t'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                bestThreshold
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-19">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                ''
               </span>
               <span class="crayon-s">
                '
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-20">
               <span class="crayon-s">
                最终结果：
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-21">
               <span class="crayon-s">
                Best Accuracy:		0.94
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-22">
               <span class="crayon-s">
                Best Feature Index:	3
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c09392798894-23">
               <span class="crayon-s">
                Best Threshold:		1.6
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c09392798894-24">
               <span class="crayon-s">
                '
               </span>
               <span class="crayon-s">
                ''
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0355 seconds] -->
       <p>
        这里我们首先对每一维度进行排序，然后从该维度中取出任一值作为阈值的一个假设，再计算这个假设的Boolean序列和实际的标签Boolean 序列的一致情况，求平均，即得到了准确率。经过所有的循环，最终得到的阈值和所对应的维度。最后，我们得到了最佳模型针对第四维花瓣的宽度petal width，我们就可以得到这个决策边界decision boundary。
       </p>
       <h3>
        评估模型——交叉检验
       </h3>
       <div>
        <p>
         上面，我们得到了一个简单的模型，并且针对训练数据实现了94%的正确率，但这个模型参数可能过于优化了。
        </p>
        <p>
         我们需要的是评估模型针对新数据的泛化能力，所以我们需要保留一部分数据，进行更加严格的评估，而不是用训练数据做测试数据。为此，我们会保留一部分数据进行交叉检验。
        </p>
        <p>
         这样我们就会得到训练误差和测试误差，当复杂的模型下，可能训练的准确率是100%，但是测试时效果可能只是比随机猜测好一点。
        </p>
       </div>
       <h4>
        交叉检验
       </h4>
       <p>
        在许多实际应用中，数据是不充足的。为了选择更好的模型，可以采用交叉检验方法。 交叉检验的基本想法是重复地使用数据；把给定数据进行切分，将切分的数据集组合为训练集和测试集，在此基础上反复地进行训练、测试以及模型选择。
       </p>
       <h4>
        S-fold交叉检验
       </h4>
       <p>
        应用最多的是S折交叉检验(S-fold cross validation)，方法如下：首先随机地将已给数据切分为S个互不相交的大小相同的子集；然后利用S-1个子集的数据训练模型，利用余下的子集测试 模型；将这一过程对可能的S种选择重复进行；最后选出S次评测中平均测试误差最小的模型。
       </p>
       <p>
        <img src="http://dataunion.org/wp-content/uploads/2014/12/141226110284203.jpg"/>
       </p>
       <p>
        如上图，我们将数据集分成5部分，即5-fold交叉检验。接下来，我们可以对每一个fold生成一个模型，留出20%的数据进行检验。
       </p>
       <h4>
        leave-one-out交叉检验方法
       </h4>
       <p>
        留一交叉检验(leave-one-out cross validation)是S折交叉检验的特殊情形，是S为给定数据集的容量时情形。我们可以从训练数据中挑选一个样本，然后拿其他训练数据得到模型，最后看该模型是否能将这个挑出来的样本正确的分类。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576861a446c13346031483" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          &lt;span class="function"&gt;&lt;span class="keyword"&gt;def&lt;/span&gt; &lt;span class="title"&gt;learn_model&lt;/span&gt;&lt;span class="params"&gt;(features,labels)&lt;/span&gt;:&lt;/span&gt;
bestAccuracy = -&lt;span class="number"&gt;1.0&lt;/span&gt;
&lt;span class="keyword"&gt;for&lt;/span&gt; fi &lt;span class="keyword"&gt;in&lt;/span&gt; xrange(features.shape[&lt;span class="number"&gt;1&lt;/span&gt;]):
thresh = features[:,fi].copy()
thresh.sort()
&lt;span class="keyword"&gt;for&lt;/span&gt; t &lt;span class="keyword"&gt;in&lt;/span&gt; thresh:
pred = (features[:,fi] &amp;gt; t)
acc = (pred == labels).mean()
&lt;span class="keyword"&gt;if&lt;/span&gt; acc &amp;gt; bestAccuracy:
bestAccuracy = acc;
bestFeatureIndex = fi;
bestThreshold = t;
&lt;span class="string"&gt;'''
print 'Best Accuracy:\t\t',bestAccuracy
print 'Best Feature Index:\t',bestFeatureIndex
print 'Best Threshold:\t\t',bestThreshold
'''&lt;/span&gt;
&lt;span class="keyword"&gt;return&lt;/span&gt; {&lt;span class="string"&gt;'dim'&lt;/span&gt;:bestFeatureIndex, &lt;span class="string"&gt;'thresh'&lt;/span&gt;:bestThreshold, &lt;span class="string"&gt;'accuracy'&lt;/span&gt;:bestAccuracy}
&lt;span class="function"&gt;&lt;span class="keyword"&gt;def&lt;/span&gt; &lt;span class="title"&gt;apply_model&lt;/span&gt;&lt;span class="params"&gt;(features,labels,model)&lt;/span&gt;:&lt;/span&gt;
prediction = (features[:,model[&lt;span class="string"&gt;'dim'&lt;/span&gt;]] &amp;gt; model[&lt;span class="string"&gt;'thresh'&lt;/span&gt;])
&lt;span class="keyword"&gt;return&lt;/span&gt; prediction
&lt;span class="comment"&gt;#-----------cross validation-------------&lt;/span&gt;
error = &lt;span class="number"&gt;0.0&lt;/span&gt;
&lt;span class="keyword"&gt;for&lt;/span&gt; ei &lt;span class="keyword"&gt;in&lt;/span&gt; range(len(irisFeatures)):
&lt;span class="comment"&gt;# select all but the one at position 'ei':&lt;/span&gt;
training = np.ones(len(irisFeatures), bool)
training[ei] = &lt;span class="built_in"&gt;False&lt;/span&gt;
testing = ~training
model = learn_model(irisFeatures[training], isVirginica[training])
predictions = apply_model(irisFeatures[testing],
  isVirginica[testing], model)
error += np.sum(predictions != isVirginica[testing])
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-576861a446c13346031483-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576861a446c13346031483-32">
               32
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576861a446c13346031483-1">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "function"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                def
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                learn_model
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "params"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                features
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                labels
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-2">
               <span class="crayon-v">
                bestAccuracy
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1.0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-3">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                xrange
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                features
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                shape
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-4">
               <span class="crayon-v">
                thresh
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                features
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                copy
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-5">
               <span class="crayon-v">
                thresh
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                sort
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-6">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                thresh
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-7">
               <span class="crayon-v">
                pred
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                features
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-8">
               <span class="crayon-v">
                acc
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                pred
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                labels
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                mean
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-9">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                acc
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                bestAccuracy
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-10">
               <span class="crayon-v">
                bestAccuracy
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                acc
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-11">
               <span class="crayon-v">
                bestFeatureIndex
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fi
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-12">
               <span class="crayon-v">
                bestThreshold
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-13">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                ''
               </span>
               <span class="crayon-s">
                '
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-14">
               <span class="crayon-s">
                print '
               </span>
               <span class="crayon-e">
                Best
               </span>
               <span class="crayon-v">
                Accuracy
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                \
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-sy">
                \
               </span>
               <span class="crayon-i">
                t
               </span>
               <span class="crayon-s">
                ',bestAccuracy
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-15">
               <span class="crayon-s">
                print '
               </span>
               <span class="crayon-e">
                Best
               </span>
               <span class="crayon-e">
                Feature
               </span>
               <span class="crayon-v">
                Index
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                \
               </span>
               <span class="crayon-i">
                t
               </span>
               <span class="crayon-s">
                ',bestFeatureIndex
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-16">
               <span class="crayon-s">
                print '
               </span>
               <span class="crayon-e">
                Best
               </span>
               <span class="crayon-v">
                Threshold
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                \
               </span>
               <span class="crayon-v">
                t
               </span>
               <span class="crayon-sy">
                \
               </span>
               <span class="crayon-i">
                t
               </span>
               <span class="crayon-s">
                ',bestThreshold
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-17">
               <span class="crayon-s">
                '
               </span>
               <span class="crayon-s">
                ''
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-18">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                return
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'dim'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-v">
                bestFeatureIndex
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'thresh'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-v">
                bestThreshold
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'accuracy'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-v">
                bestAccuracy
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-19">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "function"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                def
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "title"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-v">
                apply_model
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "params"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                features
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                labels
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                model
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-20">
               <span class="crayon-v">
                prediction
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                features
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                model
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'dim'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                model
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "string"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-s">
                'thresh'
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-21">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                return
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                prediction
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-22">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "comment"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-p">
                #-----------cross validation-------------&lt;/span&gt;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-23">
               <span class="crayon-v">
                error
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "number"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-cn">
                0.0
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-24">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ei
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "keyword"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-st">
                in
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                range
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                len
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                :
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-25">
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "comment"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-p">
                # select all but the one at position 'ei':&lt;/span&gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-26">
               <span class="crayon-v">
                training
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                ones
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                len
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                bool
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-27">
               <span class="crayon-v">
                training
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                ei
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-e">
                span
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-s">
                "built_in"
               </span>
               <span class="crayon-o">
                &gt;
               </span>
               <span class="crayon-t">
                False
               </span>
               <span class="crayon-o">
                &lt;
               </span>
               <span class="crayon-o">
                /
               </span>
               <span class="crayon-v">
                span
               </span>
               <span class="crayon-o">
                &gt;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-28">
               <span class="crayon-v">
                testing
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-e">
                training
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-29">
               <span class="crayon-v">
                model
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                learn_model
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                training
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                isVirginica
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                training
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-30">
               <span class="crayon-v">
                predictions
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                apply_model
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                irisFeatures
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                testing
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576861a446c13346031483-31">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                isVirginica
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                testing
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                model
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576861a446c13346031483-32">
               <span class="crayon-v">
                error
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +=
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                np
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                sum
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                predictions
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                !=
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                isVirginica
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                testing
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0693 seconds] -->
       <p>
        上面的程序，我们用所有的样本对一系列的模型进行了测试，最终的估计说明了模型的泛化能力。
       </p>
       <h4>
        小结
       </h4>
       <p>
        对于上面对数据集进行划分时，我们需要注意平衡分配数据。如果对于一个子集，所有的数据都来自一个类别，则结果没有代表性。基于以上的讨论，我们利用一个简单的模型来训练，交叉检验过程给出了这个模型泛化能力的估计。
       </p>
       <h3>
        参考文献
       </h3>
       <div>
        <p>
         Wiki:Iris flower data set
        </p>
        <p>
         Building Machine Learning Systems with Python
        </p>
       </div>
       <div>
        <p>
         转载请注明作者Jason Ding及其出处
        </p>
        <p>
         Github主页(http://jasonding1354.github.io/)
        </p>
        <p>
         CSDN博客(http://blog.csdn.net/jasonding1354)
        </p>
        <p>
         简书主页(http://www.jianshu.com/users/2bd9b48f6ea8/latest_articles)
        </p>
       </div>
       <div>
       </div>
       <div>
       </div>
       <div>
        文章出处：JasonDing的博客
       </div>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20820.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/1-300x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20820.html" rel="bookmark" title="人们对Python在企业级开发中的10大误解">
         人们对Python在企业级开发中的10大误解
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20758.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t012aec1078cd96f01f-300x199.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20758.html" rel="bookmark" title="推荐一些从零开始学习机器学习算法的方法">
         推荐一些从零开始学习机器学习算法的方法
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20714.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t011650727f6392a3f5-300x197.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20714.html" rel="bookmark" title="寻找最优参数解：最速下降法，牛顿下降法，阻尼牛顿法，拟牛顿法DFP/BFGS">
         寻找最优参数解：最速下降法，牛顿下降法，阻尼牛顿法，拟牛顿法DFP/BFGS
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20636.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t01034a6a3b660f0c04_副本-300x203.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20636.html" rel="bookmark" title="机器学习开发者的现代化攻略：对统计学微积分Say NO！">
         机器学习开发者的现代化攻略：对统计学微积分Say NO！
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F5583.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/5583.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/5583.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>